package com.itheima.media.controller;

import com.itheima.common.pojo.Result;
import com.itheima.media.pojo.WmUser;
import com.itheima.media.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：shenkunlin
 * @date： 2021/8/22 11:48
 * @Description：
 ***/
@RestController
@RequestMapping(value = "/wmuser")
public class LoginController {

    @Autowired
    private WmUserService wmUserService;

    /***
     * 登录
     */
    @PostMapping(value = "/login")
    public Result login(@RequestBody WmUser wmUser){
        String token = wmUserService.login(wmUser);
        if(!StringUtils.isEmpty(token)){
            return Result.ok(token);
        }
        return Result.errorMessage("账号或者密码错误！");
    }
}
